package com.netmera.mobile;

public class User {

	private NetmeraUser netmeraUser;
	private String email;
	private String forename;
	private String surname;
	private String nickname;
	private String password;
	
	private NetmeraGeoLocation netmeraGeoLocation;

	public User(String email, String nickname, String password,
			String forename, String surname) {
		this.email = email;
		this.forename = forename;
		this.surname = surname;
		this.nickname = nickname;
		this.password = password;

		createNetmeraUser();
	}

	private void createNetmeraUser() {
		netmeraUser = new NetmeraUser();

		if (!email.isEmpty() && !nickname.isEmpty() && !password.isEmpty()) {
			netmeraUser.setEmail(email);
			netmeraUser.setNickname(nickname);
			netmeraUser.setPassword(password);

			if (!forename.isEmpty()) {
				netmeraUser.setName(forename);
			}

			if (!surname.isEmpty()) {
				netmeraUser.setName(surname);
			}
			
			netmeraUser.registerInBackground(new NetmeraCallback< NetmeraUser>() {
			    @Override
			    public void callback(NetmeraUser result, NetmeraException exception) {
			            if (result != null && exception == null) {
			                // Success
			        } else {
			                // Error occurred
			        }       
			    }
			});
		}

		else {
			netmeraUser = null;
		}
	}
	
	public void updateNetmeraGeoLocation(){
		// netmeraGeoLocation = 
	}
	
}
